function [adists, assignments] = AssignObjDists(nobjsa, nobjsb, xs, ys, ex0s, ey0s)

%Dists between objects in previous frame (which has nobjsa and next frame
%which has nobjsb)
dists = zeros(nobjsb, nobjsa);
      
assignments = zeros(nobjsb, 1);
adists = zeros(nobjsb, 1);

x0a = xs;
y0a = ys;

x0b = ex0s;
y0b = ey0s;
                
for j = 1:nobjsb
    for k = 1:nobjsa
        dx = x0b(j) - x0a(k);
        dy = y0b(j) - y0a(k);
        dists(j,k) = sqrt(dx^2+dy^2);
    end
end


for j = 1:nobjsb      
    [d, index] = min(dists(j,:));
    
    adists(j) = d;
    assignments(j) = index;
    
end
